package com.zpark.bean;

import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.Valid;
import javax.validation.constraints.*;

/**
 * 在实体类中每个注解的属性message是数据校验不通过时要给出的提示信息
 * @Author: Abigale
 * @Date: 2022/10/22 10:24
 * @Version: 1.0
 */
@Data
public class User {
    @NotBlank(message = "姓名不允许为空")
    @Length(min = 2, max = 10, message = "姓名长度错误，长度2-10")
    private String name;

    @NotNull(message = "年龄不允许为空")
    @Min(value = 18,message = "年龄最小不能小于18")
    private Integer age;

    @NotBlank(message = "地址不允许为空")
    private String address;

    @Pattern(regexp = "^1(3[0-9]|5[012356789]|7[1235678]|8[0-9])\\d{8}$", message ="手机号格式错误")
    private String phone;

    @Email(message = "邮箱格式错误")
    private String email;

    @NotNull
    @Valid
    private UserDetail userDetail;
}
